package com.sunda.spmswms.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 南沙仓报表 Mapper 接口
 * </p>
 */
@Mapper
@Component
public interface WhsReportMapper {

    @Select("<script> \n" +
            "SELECT DISTINCT \n" +
            "    SBN.PACKAGE_NOTE AS \"packageNote\",\n" +
            "    SBN.BOX_NOTE AS \"boxNote\",\n" +
            "    SBN.BOX_MATERIAL_NAME AS \"boxMaterialName\",\n" +
            "    SBN.TOTAL_QTY AS \"totalQty\",\n" +
            "    SBN.BOX_GROSS_WEIGHT AS \"boxGrossWeight\",\n" +
            "    SBN.BOX_VOLUME AS \"boxVolume\",\n" +
            "    SBN.BOX_LENGTH AS \"boxLength\",\n" +
            "    SBN.BOX_WIDTH AS \"boxWidth\",\n" +
            "    SBN.BOX_HEIGHT AS \"boxHeight\",\n" +
            "    SBN.BOX_COLOR AS \"boxColor\",\n" +
            "    SBN.BOX_QTY_RECEIVED AS \"boxQtyReceived\",\n" +
            "    SBN.ITEM_STATUS AS \"itemStatus\",\n" +
            "    SBN.REMARKS AS \"remarks\",\n" +
            "    SDND.WERKS AS \"werks\",\n" +
            "    SDND.WHS_LOCATION_CODE AS \"whsLocationCode\",\n" +
            "    SDN.DELIVERY_NOTE_SAP AS \"deliveryNoteSap\",\n" +
            "    SDN.PLANNED_ARRIVAL_DATE AS \"plannedArrivalDate\",\n" +
            "    SDN.DELIVERY_NOTE_SRM AS \"deliveryNoteSrm\",\n" +
            "    SDN.CREATE_DATE_SAP AS \"createDateSap\",\n" +
            "    SDN.SPMS_MARK AS \"spmsMark\",\n" +
            "    SDN.SUPPLIER_CODE AS \"supplierCode\",\n" +
            "    SDN.SUPPLIER_DESC AS \"supplierDesc\",\n" +
            "    SDN.SPMS_STATUS AS \"spmsStatus\",\n" +
            "    SDN.DOCUMENT_DATE AS \"documentDate\",\n" +
            "    SDN.POSTING_DATE AS \"postingDate\",\n" +
            "    SDN.MOBILE_TYPE AS \"mobileType\",\n" +
            "    SDN.USER_ID AS \"userId\",\n" +
            "    SDN.PDA_SN AS \"pdaSN\",\n" +
            "    SDN.REMARKS AS \"headerRemarks\",\n" +
            "    SDN.SAP_VOUCHER_NUMBER AS \"sapVoucherNumber\",\n" +
            "    SDN.SAP_VOUCHER_YEAR AS \"sapVoucherYear\" \n" +
            "FROM\n" +
            "    SAP_BOX_NOTE SBN\n" +
            "    LEFT JOIN SAP_DELIVERY_NOTE SDN ON SBN.PACKAGE_NOTE = SDN.PACKAGE_NOTE\n" +
            "    LEFT JOIN SAP_DELIVERY_NOTE_DTL SDND ON SDN.DELIVERY_NOTE_SAP = SDND.DELIVERY_NOTE_SAP \n" +
            "WHERE\n" +
            "    SBN.BOX_QTY_RECEIVED > 0 AND SDN.SPMS_STATUS IN ('6','7','8') \n" +
            "    <when test='startDate!=null'> AND TO_DATE( SDN.DOCUMENT_DATE, 'yyyy-mm-dd' ) BETWEEN TO_DATE( #{startDate}, 'yyyy-mm-dd' ) AND TO_DATE( #{endDate}, 'yyyy-mm-dd' ) </when>\n" +
            "    <when test='werks!=null'> AND SDND.WERKS= #{werks}</when>\n" +
            "    <when test='whsLocationCode!=null'> AND SDND.WHS_LOCATION_CODE = #{whsLocationCode}</when>\n" +
            "    <when test='deliveryNoteSap!=null'> AND SDN.DELIVERY_NOTE_SAP = #{deliveryNoteSap}</when>\n" +
            "</script>")
    List<Map<String, Object>> inHouseDtlExportX(@Param("werks") String werks,
                                                @Param("whsLocationCode") String whsLocationCode,
                                                @Param("startDate") String startDate,
                                                @Param("endDate") String endDate,
                                                @Param("deliveryNoteSap") String deliveryNoteSap
    );

    @Select("<script> \n" +
            "SELECT\n" +
            "    SDND.DELIVERY_NOTE_SAP AS \"deliveryNoteSap\",\n" +
            "    SDND.DELIVERY_NOTE_SAP_ITEM AS \"deliveryNoteSapItem\",\n" +
            "    SDND.PURCHASE_GROUP AS \"purchaseGroup\",\n" +
            "    SDND.PURCHASE_GROUP_NAME AS \"purchaseGroupName\",\n" +
            "    SDND.MATERIAL_NO AS \"materialNo\",\n" +
            "    SDND.DELIVERY_QTY AS \"deliveryQty\",\n" +
            "    SDND.DELIVERY_UNIT AS \"deliveryUnit\",\n" +
            "    SDND.WERKS AS \"werks\",\n" +
            "    SDND.WHS_LOCATION_CODE AS \"whsLocationCode\",\n" +
            "    SDND.RECEIVED_QTY AS \"receivedQty\",\n" +
            "    SDND.ITEM_STATUS AS \"itemStatus\",\n" +
            "    SDND.REMARKS AS \"remarks\",\n" +
            "    SDND.TEMP_STORAGE AS \"tempStorage\",\n" +
            "    SDND.WERKS_XQ AS \"werksXq\",\n" +
            "    SDND.QTY_SALES AS \"qtySales\",\n" +
            "    SDND.ACTUAL_QTY_SALES AS \"actualQtySales\",\n" +
            "    SDN.PLANNED_ARRIVAL_DATE AS \"plannedArrivalDate\",\n" +
            "    SDN.DELIVERY_TYPE AS \"deliveryType\",\n" +
            "    SDN.DELIVERY_NOTE_SRM AS \"deliveryNoteSrm\",\n" +
            "    SDN.CREATE_DATE_SAP AS \"createDateSap\",\n" +
            "    SDN.SPMS_MARK AS \"spmsMark\",\n" +
            "    SDN.SUPPLIER_CODE AS \"supplierCode\",\n" +
            "    SDN.SUPPLIER_DESC AS \"supplierDesc\",\n" +
            "    SDN.SPMS_STATUS AS \"spmsStatus\",\n" +
            "    SDN.PACKAGE_NOTE AS \"packageNote\",\n" +
            "    SDN.REMARKS AS \"headerRemarks\",\n" +
            "    SDN.DOCUMENT_DATE AS \"documentDate\",\n" +
            "    SDN.POSTING_DATE AS \"postingDate\",\n" +
            "    SDN.MOBILE_TYPE AS \"mobileType\",\n" +
            "    SDN.USER_ID AS \"userId\",\n" +
            "    SDN.PDA_SN AS \"pdaSN\",\n" +
            "    SDN.SAP_VOUCHER_NUMBER AS \"sapVoucherNumber\",\n" +
            "    SDN.SAP_VOUCHER_YEAR AS \"sapVoucherYear\",\n" +
            "    MA.MATERIAL_ZH_DESC AS \"materialZhDesc\",\n" +
            "    MA.MATERIAL_EN_DESC AS \"materialEnDesc\",\n" +
            "    MA.BASIC_UNIT AS \"basicUnit\",\n" +
            "    MA.UNIT_SALES AS \"unitSales\",\n" +
            "    MA.NET_WEIGHT AS \"netWeight\",\n" +
            "    MA.GROSS_WEIGHT AS \"grossWeight\",\n" +
            "    MA.WEIGHT_UNIT AS \"weightUnit\",\n" +
            "    MA.VOLUME_QTY AS \"volumeQty\",\n" +
            "    MA.VOLUME_UNIT AS \"volumeUnit\",\n" +
            "    MA.LIGHT_HEAVY_MARK AS \"lightHeavyMark\",\n" +
            "    (CASE WHEN MA.NUMERATOR IS NULL THEN 1 ELSE MA.NUMERATOR END ) AS \"numerator\",\n" +
            "    (CASE WHEN MA.DENOMINATOR IS NULL THEN 1 ELSE MA.DENOMINATOR END ) AS \"denominator\" \n" +
            "    FROM\n" +
            "        SAP_DELIVERY_NOTE_DTL SDND\n" +
            "        LEFT JOIN SAP_DELIVERY_NOTE SDN ON SDND.DELIVERY_NOTE_SAP = SDN.DELIVERY_NOTE_SAP \n" +
            "        LEFT JOIN MATERIAL_SAP MA ON SDND.MATERIAL_NO = MA.MATERIAL_NO\n" +
            "    WHERE\n" +
            "        SDND.RECEIVED_QTY > 0 AND SDN.SPMS_STATUS IN ('6','7','8') \n" +
            "    <when test='startDate!=null'> AND TO_DATE( SDN.DOCUMENT_DATE, 'yyyy-mm-dd' ) BETWEEN TO_DATE( #{startDate}, 'yyyy-mm-dd' ) AND TO_DATE( #{endDate}, 'yyyy-mm-dd' ) </when>\n" +
            "    <when test='werks!=null'> AND SDND.WERKS= #{werks}</when>\n" +
            "    <when test='whsLocationCode!=null'> AND SDND.WHS_LOCATION_CODE = #{whsLocationCode}</when>\n" +
            "    <when test='deliveryNoteSap!=null'> AND SDN.DELIVERY_NOTE_SAP = #{deliveryNoteSap}</when>\n" +
            "</script>")
    List<Map<String, Object>> inHouseDtlExportM(@Param("werks") String werks,
                                                @Param("whsLocationCode") String whsLocationCode,
                                                @Param("startDate") String startDate,
                                                @Param("endDate") String endDate,
                                                @Param("deliveryNoteSap") String deliveryNoteSap
    );

    @Select("<script> \n" +
            "SELECT\n" +
            "    '海运出库' AS \"Source\",\n" +
            "    SPLD.PACKAGE_LIST AS \"packageList\",\n" +
            "    SPLD.DATE_OF_LOADING AS \"dateOfLoading\",\n" +
            "    SPLD.LOADING_WERKS AS \"loadingWerks\",\n" +
            "    SPLD.LOADING_WHS_LOCATION_CODE AS \"loadingWhsLocationCode\",\n" +
            "    SPLD.CABINET_SERIAL_NUMBER AS \"cabinetSerialNumber\",\n" +
            "    SPLD.GOODS_TYPE AS \"goodsType\",\n" +
            "    SPLD.RECEIVING_WERKS AS \"receivingWerks\",\n" +
            "    SPLD.ACTUAL_RECEIVING_WERKS AS \"actualReceivingWerks\",\n" +
            "    SPLD.MATERIAL_NO AS \"materialNo\",\n" +
            "    SPLD.SHIPMENT_CATEGORY AS \"shipmentCategory\",\n" +
            "    SPLD.PLANNED_PACKING_QTY AS \"plannedPackingQty\",\n" +
            "    SPLD.BASIC_UNIT AS \"basicUnit\",\n" +
            "    SPLD.PLANNED_PACKING_NUMBER AS \"plannedPackingNumber\",\n" +
            "    SPLD.PACKING_UNIT AS \"packingUnit\",\n" +
            "    SPLD.CABINET_WEIGHT AS \"cabinetWeight\",\n" +
            "    SPLD.WEIGHT_UNIT AS \"weightUnit\",\n" +
            "    SPLD.CABINET_VOLUME AS \"cabinetVolume\",\n" +
            "    SPLD.VOLUME_UNIT AS \"volumeUnit\",\n" +
            "    SPLD.TRAILER_LINE AS \"trailerLine\",\n" +
            "    SPLD.TRAILER_LINE_DESC AS \"trailerLineDesc\",\n" +
            "    SPLD.SPMS_STATUS AS \"spmsStatus\",\n" +
            "    SPLD.WHS_OUT_UUID AS \"outUuid\",\n" +
            "    SPLD.TEMP_STORAGE AS \"tempStorage\",\n" +
            "    SPLD.UNPLANNED AS \"unplanned\",\n" +
            "    SPLD.ACTUAL_OPERATE_QTY AS \"actualOperateQty\",\n" +
            "    SPLD.CONTAINER_BRAND AS \"containerBrand\",\n" +
            "    SPLD.COLOR_NUMBER AS \"colorNumber\",\n" +
            "    SPLD.THICKNESS AS \"thickness\",\n" +
            "    SPLD.ACTUAL_AVG_GROSS_WEIGHT AS \"actualAvgGrossWeight\",\n" +
            "    SPLD.ACTUAL_PACKING_NUMBER AS \"actualPackingNumber\",\n" +
            "    SPLD.CUSTOMS_DECLARATION_NUMBER AS \"customsDeclarationNumber\",\n" +
            "    SPLD.PACKING_SPEC AS \"packingSpec\",\n" +
            "    SPLD.LOADING_TYPE AS \"loadingType\",\n" +
            "    WHSOUT.CABINET_NUMBER AS \"cabinetNumber\",\n" +
            "    WHSOUT.WHS_OUT_NO AS \"spmsId\",\n" +
            "    WHSOUT.LEAD_SEAL AS \"leadSeal\",\n" +
            "    WHSOUT.SAP_VOUCHER_NUMBER AS \"sapVoucherNumber\",\n" +
            "    WHSOUT.SAP_VOUCHER_YEAR AS \"sapVoucherYear\",\n" +
            "    WHSOUT.ACTUAL_LOADING_DATE AS \"actualLoadingDate\",\n" +
            "    WHSOUT.MONITOR_LOADING AS \"monitorLoading\",\n" +
            "    WHSOUT.CABINET_CHECK_RESULT AS \"cabinetCheckResult\",\n" +
            "    WHSOUT.REMARKS AS \"remarks\",\n" +
            "    MA.MATERIAL_ZH_DESC AS \"materialZhDesc\",\n" +
            "    MA.MATERIAL_EN_DESC AS \"materialEnDesc\",\n" +
            "    MA.UNIT_SALES AS \"unitSales\",\n" +
            "    MA.NET_WEIGHT AS \"netWeight\",\n" +
            "    MA.GROSS_WEIGHT AS \"grossWeight\",\n" +
            "    MA.WEIGHT_UNIT AS \"weightUnit\",\n" +
            "    MA.VOLUME_QTY AS \"volumeQty\",\n" +
            "    MA.VOLUME_UNIT AS \"volumeUnit\",\n" +
            "    MA.LIGHT_HEAVY_MARK AS \"lightHeavyMark\" \n" +
            "FROM\n" +
            "    SAP_PACKAGE_LIST_DTL SPLD\n" +
            "    LEFT JOIN WHS_OUT WHSOUT ON SPLD.WHS_OUT_UUID = WHSOUT.UUID\n" +
            "    LEFT JOIN MATERIAL_SAP MA ON SPLD.MATERIAL_NO = MA.MATERIAL_NO \n" +
            "WHERE\n" +
            "    SPLD.ACTUAL_OPERATE_QTY > 0 \n" +
            "    AND WHSOUT.TASK_STATUS IN ( '2', '4', '5' )\n" +
            "    <when test='startDate!=null'> AND TO_DATE( WHSOUT.ACTUAL_LOADING_DATE, 'yyyy-mm-dd' ) BETWEEN TO_DATE( #{startDate}, 'yyyy-mm-dd' ) AND TO_DATE( #{endDate}, 'yyyy-mm-dd' ) </when>\n" +
            "    <when test='werks!=null'> AND SPLD.LOADING_WERKS= #{werks}</when>\n" +
            "    <when test='whsLocationCode!=null'> AND SPLD.LOADING_WHS_LOCATION_CODE = #{whsLocationCode}</when>\n" +
            "    <when test='packageList!=null'> AND SPLD.PACKAGE_LIST = #{packageList}</when>\n" +
            "UNION \n" +
            "SELECT\n" +
            "    '其它出入库' AS \"Source\",\n" +
            "    WHSO.PACKAGE_LIST AS \"packageList\",\n" +
            "    WHSODTL.DATE_OF_LOADING AS \"dateOfLoading\",\n" +
            "    WHSODTL.WERKS AS \"loadingWerks\",\n" +
            "    WHSODTL.WHS_LOCATION_CODE AS \"loadingWhsLocationCode\",\n" +
            "    WHSODTL.CABINET_SERIAL_NUMBER AS \"cabinetSerialNumber\",\n" +
            "    WHSO.GOODS_TYPE AS \"goodsType\",\n" +
            "    WHSODTL.RECEIVING_WERKS AS \"receivingWerks\",\n" +
            "    WHSODTL.ACTUAL_RECEIVING_WERKS AS \"actualReceivingWerks\",\n" +
            "    WHSODTL.MATERIAL_NO AS \"materialNo\",\n" +
            "    WHSODTL.SHIPMENT_CATEGORY AS \"shipmentCategory\",\n" +
            "    WHSODTL.PLANNED_PACKING_QTY AS \"plannedPackingQty\",\n" +
            "    MA.BASIC_UNIT AS \"basicUnit\",\n" +
            "    WHSODTL.PLANNED_PACKING_NUMBER AS \"plannedPackingNumber\",\n" +
            "    WHSODTL.PACKAGE_UNIT AS \"packingUnit\",\n" +
            "    WHSODTL.CABINET_WEIGHT AS \"cabinetWeight\",\n" +
            "    WHSODTL.WEIGHT_UNIT AS \"weightUnit\",\n" +
            "    WHSODTL.CABINET_VOLUME AS \"cabinetVolume\",\n" +
            "    WHSODTL.VOLUME_UNIT AS \"volumeUnit\",\n" +
            "    WHSODTL.TRAILER_LINE AS \"trailerLine\",\n" +
            "    WHSODTL.TRAILER_LINE_DESC AS \"trailerLineDesc\",\n" +
            "    WHSODTL.SPMS_STATUS AS \"spmsStatus\",\n" +
            "    WHSODTL.WHS_OTHER_UUID AS \"outUuid\",\n" +
            "    WHSODTL.TEMP_STORAGE AS \"tempStorage\",\n" +
            "    WHSODTL.UNPLANNED AS \"unplanned\",\n" +
            "    WHSODTL.OPERATE_QTY AS \"actualOperateQty\",\n" +
            "    WHSODTL.CONTAINER_BRAND AS \"containerBrand\",\n" +
            "    WHSODTL.COLOR_NUMBER AS \"colorNumber\",\n" +
            "    WHSODTL.THICKNESS AS \"thickness\",\n" +
            "    WHSODTL.ACTUAL_AVG_GROSS_WEIGHT AS \"actualAvgGrossWeight\",\n" +
            "    WHSODTL.PACKAGE_QTY AS \"actualPackingNumber\",\n" +
            "    WHSODTL.CUSTOMS_DECLARATION_NUMBER AS \"customsDeclarationNumber\",\n" +
            "    WHSODTL.PACKING_SPEC AS \"packingSpec\",\n" +
            "    WHSODTL.LOADING_TYPE AS \"loadingType\",\n" +
            "    WHSODTL.CABINET_NUMBER AS \"cabinetNumber\",\n" +
            "    WHSO.SPMS_ID AS \"spmsId\",\n" +
            "    WHSODTL.LEAD_SEAL AS \"leadSeal\",\n" +
            "    WHSO.SAP_VOUCHER_NUMBER AS \"sapVoucherNumber\",\n" +
            "    WHSO.SAP_VOUCHER_YEAR AS \"sapVoucherYear\",\n" +
            "    WHSO.ACTUAL_LOADING_DATE AS \"actualLoadingDate\",\n" +
            "    WHSO.MONITOR_LOADING AS \"monitorLoading\",\n" +
            "    WHSO.CABINET_CHECK_RESULT AS \"cabinetCheckResult\",\n" +
            "    WHSODTL.ROW_REMARKS AS \"remarks\",\n" +
            "    MA.MATERIAL_ZH_DESC AS \"materialZhDesc\",\n" +
            "    MA.MATERIAL_EN_DESC AS \"materialEnDesc\",\n" +
            "    MA.UNIT_SALES AS \"unitSales\",\n" +
            "    MA.NET_WEIGHT AS \"netWeight\",\n" +
            "    MA.GROSS_WEIGHT AS \"grossWeight\",\n" +
            "    MA.WEIGHT_UNIT AS \"weightUnit\",\n" +
            "    MA.VOLUME_QTY AS \"volumeQty\",\n" +
            "    MA.VOLUME_UNIT AS \"volumeUnit\",\n" +
            "    MA.LIGHT_HEAVY_MARK AS \"lightHeavyMark\" \n" +
            "FROM\n" +
            "    WHS_OTHER_DTL WHSODTL\n" +
            "    LEFT JOIN WHS_OTHER_TASK WHSO ON WHSODTL.WHS_OTHER_UUID = WHSO.UUID\n" +
            "    LEFT JOIN MATERIAL_SAP MA ON WHSODTL.MATERIAL_NO = MA.MATERIAL_NO \n" +
            "WHERE\n" +
            "    WHSO.MOVEMENT_TYPE = 'Z641' \n" +
            "    AND WHSO.TASK_STATUS IN ( '3', '4', '5', '6' ) \n" +
            "    AND WHSO.GOODS_TYPE = 'M' \n" +
            "    <when test='startDate!=null'> AND TO_DATE( WHSO.ACTUAL_LOADING_DATE, 'yyyy-mm-dd' ) BETWEEN TO_DATE( #{startDate}, 'yyyy-mm-dd' ) AND TO_DATE( #{endDate}, 'yyyy-mm-dd' ) </when>\n" +
            "    <when test='werks!=null'> AND WHSODTL.WERKS= #{werks}</when>\n" +
            "    <when test='whsLocationCode!=null'> AND WHSODTL.WHS_LOCATION_CODE = #{whsLocationCode}</when>\n" +
            "    <when test='packageList!=null'> AND WHSO.PACKAGE_LIST = #{packageList}</when>\n" +
            "</script>")
    List<Map<String, Object>> outHouseDtlExportM(@Param("werks") String werks,
                                                 @Param("whsLocationCode") String whsLocationCode,
                                                 @Param("startDate") String startDate,
                                                 @Param("endDate") String endDate,
                                                 @Param("packageList") String packageList
    );

    @Select("<script> \n" +
            "SELECT DISTINCT\n" +
            "    '海运出库' AS \"Source\",\n" +
            "    SPB.PACKAGE_LIST AS \"packageList\" ,\n" +
            "    SPB.BOX_NOTE AS \"boxNote\",\n" +
            "    SPB.ACTUAL_OPERATE_QTY AS \"actualOperateQty\",\n" +
            "    SPB.WHS_OUT_UUID AS \"outUuid\",\n" +
            "    SPB.CONTAINER_BRAND AS \"containerBrand\",\n" +
            "    SPB.PACKING_SPEC AS \"packingSpec\",\n" +
            "    SPB.LOADING_TYPE AS \"loadingType\",\n" +
            "    WHSOUT.WHS_OUT_NO AS \"spmsId\",\n" +
            "    WHSOUT.WERKS AS \"werks\",\n" +
            "    WHSOUT.WHS_LOCATION_CODE AS \"whsLocationCode\",\n" +
            "    WHSOUT.GOODS_TYPE AS \"goodsType\",\n" +
            "    WHSOUT.CABINET_NUMBER AS \"cabinetNumber\",\n" +
            "    WHSOUT.CABINET_SERIAL_NUMBER AS \"cabinetSerialNumber\",\n" +
            "    WHSOUT.SAP_VOUCHER_NUMBER AS \"sapVoucherNumber\",\n" +
            "    WHSOUT.SAP_VOUCHER_YEAR AS \"sapVoucherYear\",\n" +
            "    WHSOUT.ACTUAL_LOADING_DATE AS \"actualLoadingDate\",\n" +
            "    WHSOUT.MONITOR_LOADING AS \"monitorLoading\",\n" +
            "    WHSOUT.CABINET_CHECK_RESULT AS \"cabinetCheckResult\",\n" +
            "    WHSOUT.LEAD_SEAL AS \"leadSeal\"\n" +
            "FROM\n" +
            "    SAP_PACKAGE_BOX SPB\n" +
            "    LEFT JOIN WHS_OUT WHSOUT ON SPB.WHS_OUT_UUID = WHSOUT.UUID \n" +
            "WHERE\n" +
            "    SPB.ACTUAL_OPERATE_QTY > 0 AND WHSOUT.TASK_STATUS IN ('2','4','5') \n" +
            "    <when test='startDate!=null'> AND TO_DATE( WHSOUT.ACTUAL_LOADING_DATE, 'yyyy-mm-dd' ) BETWEEN TO_DATE( #{startDate}, 'yyyy-mm-dd' ) AND TO_DATE( #{endDate}, 'yyyy-mm-dd' ) </when>\n" +
            "    <when test='werks!=null'> AND WHSOUT.WERKS= #{werks}</when>\n" +
            "    <when test='whsLocationCode!=null'> AND WHSOUT.WHS_LOCATION_CODE = #{whsLocationCode}</when>\n" +
            "    <when test='packageList!=null'> AND SPB.PACKAGE_LIST = #{packageList}</when>\n" +
            "UNION \n" +
            "SELECT DISTINCT\n" +
            "    '其它出入库' AS \"Source\",\n" +
            "    WHSO.PACKAGE_LIST AS \"packageList\",\n" +
            "    WHSODTL.BOX_NOTE AS \"boxNote\",\n" +
            "    WHSODTL.OPERATE_QTY AS \"actualOperateQty\",\n" +
            "    WHSODTL.WHS_OTHER_UUID AS \"outUuid\",\n" +
            "    WHSODTL.CONTAINER_BRAND AS \"containerBrand\",\n" +
            "    WHSODTL.PACKING_SPEC AS \"packingSpec\",\n" +
            "    WHSODTL.LOADING_TYPE AS \"loadingType\",\n" +
            "    WHSO.SPMS_ID AS \"spmsId\",\n" +
            "    WHSODTL.WERKS AS \"werks\",\n" +
            "    WHSODTL.WHS_LOCATION_CODE AS \"whsLocationCode\",\n" +
            "    WHSO.GOODS_TYPE AS \"goodsType\",\n" +
            "    WHSODTL.CABINET_NUMBER AS \"cabinetNumber\",\n" +
            "    WHSODTL.CABINET_SERIAL_NUMBER AS \"cabinetSerialNumber\",\n" +
            "    WHSO.SAP_VOUCHER_NUMBER AS \"sapVoucherNumber\",\n" +
            "    WHSO.SAP_VOUCHER_YEAR AS \"sapVoucherYear\",\n" +
            "    WHSO.ACTUAL_LOADING_DATE AS \"actualLoadingDate\",\n" +
            "    WHSO.MONITOR_LOADING AS \"monitorLoading\",\n" +
            "    WHSO.CABINET_CHECK_RESULT AS \"cabinetCheckResult\",\n" +
            "    WHSO.LEAD_SEAL AS \"leadSeal\" \n" +
            "FROM\n" +
            "    WHS_OTHER_DTL WHSODTL\n" +
            "    LEFT JOIN WHS_OTHER_TASK WHSO ON WHSODTL.WHS_OTHER_UUID = WHSO.UUID\n" +
            "WHERE\n" +
            "    WHSO.MOVEMENT_TYPE = 'Z641' \n" +
            "    AND WHSO.TASK_STATUS IN ( '3', '4', '5', '6' ) \n" +
            "    AND WHSO.GOODS_TYPE = 'X' \n" +
            "    <when test='startDate!=null'> AND TO_DATE( WHSO.ACTUAL_LOADING_DATE, 'yyyy-mm-dd' ) BETWEEN TO_DATE( #{startDate}, 'yyyy-mm-dd' ) AND TO_DATE( #{endDate}, 'yyyy-mm-dd' ) </when>\n" +
            "    <when test='werks!=null'> AND WHSODTL.WERKS= #{werks}</when>\n" +
            "    <when test='whsLocationCode!=null'> AND WHSODTL.WHS_LOCATION_CODE = #{whsLocationCode}</when>\n" +
            "    <when test='packageList!=null'> AND WHSO.PACKAGE_LIST = #{packageList}</when>\n" +
            "</script>")
    List<Map<String, Object>> outHouseDtlExportX(@Param("werks") String werks,
                                                 @Param("whsLocationCode") String whsLocationCode,
                                                 @Param("startDate") String startDate,
                                                 @Param("endDate") String endDate,
                                                 @Param("packageList") String packageList
    );


    @Select("<script> \n" +
            "SELECT\n" +
            "    '海运出库' AS \"Source\",\n" +
            "    SPB.PACKAGE_LIST AS \"packageList\",\n" +
            "    SPB.BOX_NOTE AS \"boxNote\",\n" +
            "    SPB.ACTUAL_OPERATE_QTY AS \"actualOperateQty\",\n" +
            "    SPB.WHS_OUT_UUID AS \"outUuid\",\n" +
            "    SPB.CONTAINER_BRAND AS \"containerBrand\",\n" +
            "    SPB.PACKING_SPEC AS \"packingSpec\",\n" +
            "    SPB.LOADING_TYPE AS \"loadingType\",\n" +
            "    WHSOUT.WHS_OUT_NO AS \"spmsId\",\n" +
            "    WHSOUT.WERKS AS \"werks\",\n" +
            "    WHSOUT.WHS_LOCATION_CODE AS \"whsLocationCode\",\n" +
            "    WHSOUT.GOODS_TYPE AS \"goodsType\",\n" +
            "    WHSOUT.CABINET_NUMBER AS \"cabinetNumber\",\n" +
            "    WHSOUT.CABINET_SERIAL_NUMBER AS \"cabinetSerialNumber\",\n" +
            "    WHSOUT.SAP_VOUCHER_NUMBER AS \"sapVoucherNumber\",\n" +
            "    WHSOUT.SAP_VOUCHER_YEAR AS \"sapVoucherYear\",\n" +
            "    WHSOUT.ACTUAL_LOADING_DATE AS \"actualLoadingDate\",\n" +
            "    WHSOUT.MONITOR_LOADING AS \"monitorLoading\",\n" +
            "    WHSOUT.CABINET_CHECK_RESULT AS \"cabinetCheckResult\",\n" +
            "    WHSOUT.LEAD_SEAL AS \"leadSeal\",\n" +
            "    SBN.BOX_MATERIAL_NAME AS \"boxMaterialName\",\n" +
            "    SBN.BOX_GROSS_WEIGHT AS \"boxGrossWeight\",\n" +
            "    SBN.BOX_VOLUME AS \"boxVolume\",\n" +
            "    BND.DELIVERY_NOTE_SAP AS \"deliveryNoteSap\",\n" +
            "    BND.MATERIAL_NO AS \"materialNo\",\n" +
            "    BND.BASIC_UNIT AS \"basicUnit\",\n" +
            "    BND.SPECS AS \"specs\",\n" +
            "    BND.QUANTITY AS \"qty\",\n" +
            "    BND.SRM_CONTRACT_NO AS \"srmContractNo\",\n" +
            "    BND.PURCHASE_NO AS \"purchaseNo\",\n" +
            "    BND.DEMAND_NO AS \"demandNo\",\n" +
            "    BND.DEMAND_NO_ITEM AS \"demandNoItem\",\n" +
            "    BND.DEMANDER AS \"demander\",\n" +
            "    BND.DOMESTIC_QTY_RECEIVABLE AS \"domesticQtyReceivable\",\n" +
            "    BND.DOMESTIC_QTY_RECEIVED AS \"domesticQtyReceived\",\n" +
            "    BND.OVERSEA_QTY_RECEIVED AS \"overseaQtyReceived\",\n" +
            "    MA.MATERIAL_ZH_DESC AS \"materialZhDesc\",\n" +
            "    MA.MATERIAL_EN_DESC AS \"materialEnDesc\",\n" +
            "    MA.UNIT_SALES AS \"unitSales\",\n" +
            "    MA.NET_WEIGHT AS \"netWeight\",\n" +
            "    MA.GROSS_WEIGHT AS \"grossWeight\",\n" +
            "    MA.WEIGHT_UNIT AS \"weightUnit\",\n" +
            "    MA.VOLUME_QTY AS \"volumeQty\",\n" +
            "    MA.VOLUME_UNIT AS \"volumeUnit\",\n" +
            "    (CASE WHEN MA.NUMERATOR IS NULL THEN 1 ELSE MA.NUMERATOR END ) AS \"numerator\",\n" +
            "    (CASE WHEN MA.DENOMINATOR IS NULL THEN 1 ELSE MA.DENOMINATOR END ) AS \"denominator\" ,\n" +
            "    MA.LIGHT_HEAVY_MARK AS \"lightHeavyMark\" \n" +
            "FROM\n" +
            "    SAP_PACKAGE_BOX SPB\n" +
            "    LEFT JOIN WHS_OUT WHSOUT ON SPB.WHS_OUT_UUID = WHSOUT.UUID\n" +
            "    LEFT JOIN SAP_BOX_NOTE SBN ON SPB.BOX_NOTE = SBN.BOX_NOTE\n" +
            "    JOIN SAP_BOX_NOTE_DTL BND ON SPB.BOX_NOTE = BND.BOX_NOTE\n" +
            "    JOIN MATERIAL_SAP MA ON BND.MATERIAL_NO = MA.MATERIAL_NO \n" +
            "WHERE\n" +
            "    SPB.ACTUAL_OPERATE_QTY > 0 AND WHSOUT.TASK_STATUS IN ('2','4','5') \n" +
            "    <when test='cabinetNumber!=null'> AND WHSOUT.CABINET_NUMBER = #{cabinetNumber}</when>\n" +
            "    <when test='packageList!=null'> AND SPB.PACKAGE_LIST = #{packageList}</when>\n" +
            "UNION \n" +
            "SELECT\n" +
            "    '其它出入库' AS \"Source\",\n" +
            "    WHSO.PACKAGE_LIST AS \"packageList\",\n" +
            "    WHSODTL.BOX_NOTE AS \"boxNote\",\n" +
            "    WHSODTL.OPERATE_QTY AS \"actualOperateQty\",\n" +
            "    WHSODTL.WHS_OTHER_UUID AS \"outUuid\",\n" +
            "    WHSODTL.CONTAINER_BRAND AS \"containerBrand\",\n" +
            "    WHSODTL.PACKING_SPEC AS \"packingSpec\",\n" +
            "    WHSODTL.LOADING_TYPE AS \"loadingType\",\n" +
            "    WHSO.SPMS_ID AS \"spmsId\",\n" +
            "    WHSODTL.WERKS AS \"werks\",\n" +
            "    WHSODTL.WHS_LOCATION_CODE AS \"whsLocationCode\",\n" +
            "    WHSO.GOODS_TYPE AS \"goodsType\",\n" +
            "    WHSODTL.CABINET_NUMBER AS \"cabinetNumber\",\n" +
            "    WHSODTL.CABINET_SERIAL_NUMBER AS \"cabinetSerialNumber\",\n" +
            "    WHSO.SAP_VOUCHER_NUMBER AS \"sapVoucherNumber\",\n" +
            "    WHSO.SAP_VOUCHER_YEAR AS \"sapVoucherYear\",\n" +
            "    WHSO.ACTUAL_LOADING_DATE AS \"actualLoadingDate\",\n" +
            "    WHSO.MONITOR_LOADING AS \"monitorLoading\",\n" +
            "    WHSO.CABINET_CHECK_RESULT AS \"cabinetCheckResult\",\n" +
            "    WHSO.LEAD_SEAL AS \"leadSeal\",\n" +
            "    SBN.BOX_MATERIAL_NAME AS \"boxMaterialName\",\n" +
            "    SBN.BOX_GROSS_WEIGHT AS \"grossWeight\",\n" +
            "    SBN.BOX_VOLUME AS \"boxVolume\",\n" +
            "    BND.DELIVERY_NOTE_SAP AS \"deliveryNoteSap\",\n" +
            "    BND.MATERIAL_NO AS \"materialNo\",\n" +
            "    BND.BASIC_UNIT AS \"basicUnit\",\n" +
            "    BND.SPECS AS \"specs\",\n" +
            "    BND.QUANTITY AS \"qty\",\n" +
            "    BND.SRM_CONTRACT_NO AS \"srmContractNo\",\n" +
            "    BND.PURCHASE_NO AS \"purchaseNo\",\n" +
            "    BND.DEMAND_NO AS \"demandNo\",\n" +
            "    BND.DEMAND_NO_ITEM AS \"demandNoItem\",\n" +
            "    BND.DEMANDER AS \"demander\",\n" +
            "    BND.DOMESTIC_QTY_RECEIVABLE AS \"domesticQtyReceivable\",\n" +
            "    BND.DOMESTIC_QTY_RECEIVED AS \"domesticQtyReceived\",\n" +
            "    BND.OVERSEA_QTY_RECEIVED AS \"overseaQtyReceived\",\n" +
            "    MA.MATERIAL_ZH_DESC AS \"materialZhDesc\",\n" +
            "    MA.MATERIAL_EN_DESC AS \"materialEnDesc\",\n" +
            "    MA.UNIT_SALES AS \"unitSales\",\n" +
            "    MA.NET_WEIGHT AS \"netWeight\",\n" +
            "    MA.GROSS_WEIGHT AS \"grossWeight\",\n" +
            "    MA.WEIGHT_UNIT AS \"weightUnit\",\n" +
            "    MA.VOLUME_QTY AS \"volumeQty\",\n" +
            "    MA.VOLUME_UNIT AS \"volumeUnit\",\n" +
            "    (CASE WHEN MA.NUMERATOR IS NULL THEN 1 ELSE MA.NUMERATOR END ) AS \"numerator\",\n" +
            "    (CASE WHEN MA.DENOMINATOR IS NULL THEN 1 ELSE MA.DENOMINATOR END ) AS \"denominator\" ,\n" +
            "    MA.LIGHT_HEAVY_MARK AS \"lightHeavyMark\" \n" +
            "FROM\n" +
            "    WHS_OTHER_DTL WHSODTL\n" +
            "    LEFT JOIN WHS_OTHER_TASK WHSO ON WHSODTL.WHS_OTHER_UUID = WHSO.UUID\n" +
            "    LEFT JOIN SAP_BOX_NOTE SBN ON WHSODTL.BOX_NOTE = SBN.BOX_NOTE\n" +
            "    JOIN SAP_BOX_NOTE_DTL BND ON WHSODTL.BOX_NOTE = BND.BOX_NOTE\n" +
            "    JOIN MATERIAL_SAP MA ON BND.MATERIAL_NO = MA.MATERIAL_NO \n" +
            "WHERE\n" +
            "    WHSO.MOVEMENT_TYPE = 'Z641' \n" +
            "    AND WHSO.TASK_STATUS IN ( '3', '4', '5', '6' ) \n" +
            "    AND WHSO.GOODS_TYPE = 'X' \n" +
            "    <when test='cabinetNumber!=null'> AND WHSODTL.CABINET_NUMBER = #{cabinetNumber}</when>\n" +
            "    <when test='packageList!=null'> AND WHSO.PACKAGE_LIST = #{packageList}</when>\n" +
            "</script>")
    List<Map<String, Object>> outWHExportX(
            @Param("cabinetNumber") String cabinetNumber,
            @Param("packageList") String packageList
    );


    @Select("<script> \n" +
            "SELECT\n" +
            "    '海运出库' AS \"Source\",\n" +
            "    SPLD.PACKAGE_LIST AS \"packageList\",\n" +
            "    SPLD.DATE_OF_LOADING AS \"dateOfLoading\",\n" +
            "    SPLD.LOADING_WERKS AS \"loadingWerks\",\n" +
            "    SPLD.LOADING_WHS_LOCATION_CODE AS \"loadingWhsLocationCode\",\n" +
            "    SPLD.CABINET_SERIAL_NUMBER AS \"cabinetSerialNumber\",\n" +
            "    SPLD.GOODS_TYPE AS \"goodsType\",\n" +
            "    SPLD.RECEIVING_WERKS AS \"receivingWerks\",\n" +
            "    SPLD.ACTUAL_RECEIVING_WERKS AS \"actualReceivingWerks\",\n" +
            "    SPLD.MATERIAL_NO AS \"materialNo\",\n" +
            "    SPLD.SHIPMENT_CATEGORY AS \"shipmentCategory\",\n" +
            "    SPLD.PLANNED_PACKING_QTY AS \"plannedPackingQty\",\n" +
            "    SPLD.BASIC_UNIT AS \"basicUnit\",\n" +
            "    SPLD.PLANNED_PACKING_NUMBER AS \"plannedPackingNumber\",\n" +
            "    SPLD.PACKING_UNIT AS \"packingUnit\",\n" +
            "    SPLD.CABINET_WEIGHT AS \"cabinetWeight\",\n" +
            "    SPLD.WEIGHT_UNIT AS \"weightUnit\",\n" +
            "    SPLD.CABINET_VOLUME AS \"cabinetVolume\",\n" +
            "    SPLD.VOLUME_UNIT AS \"volumeUnit\",\n" +
            "    SPLD.TRAILER_LINE AS \"trailerLine\",\n" +
            "    SPLD.TRAILER_LINE_DESC AS \"trailerLineDesc\",\n" +
            "    SPLD.SPMS_STATUS AS \"spmsStatus\",\n" +
            "    SPLD.WHS_OUT_UUID AS \"outUuid\",\n" +
            "    SPLD.TEMP_STORAGE AS \"tempStorage\",\n" +
            "    SPLD.UNPLANNED AS \"unplanned\",\n" +
            "    SPLD.ACTUAL_OPERATE_QTY AS \"actualOperateQty\",\n" +
            "    SPLD.CONTAINER_BRAND AS \"containerBrand\",\n" +
            "    SPLD.COLOR_NUMBER AS \"colorNumber\",\n" +
            "    SPLD.THICKNESS AS \"thickness\",\n" +
            "    SPLD.ACTUAL_AVG_GROSS_WEIGHT AS \"actualAvgGrossWeight\",\n" +
            "    SPLD.ACTUAL_PACKING_NUMBER AS \"actualPackingNumber\",\n" +
            "    SPLD.CUSTOMS_DECLARATION_NUMBER AS \"customsDeclarationNumber\",\n" +
            "    SPLD.PACKING_SPEC AS \"packingSpec\",\n" +
            "    SPLD.LOADING_TYPE AS \"loadingType\",\n" +
            "    WHSOUT.CABINET_NUMBER AS \"cabinetNumber\",\n" +
            "    WHSOUT.WHS_OUT_NO AS \"spmsId\",\n" +
            "    WHSOUT.LEAD_SEAL AS \"leadSeal\",\n" +
            "    WHSOUT.SAP_VOUCHER_NUMBER AS \"sapVoucherNumber\",\n" +
            "    WHSOUT.SAP_VOUCHER_YEAR AS \"sapVoucherYear\",\n" +
            "    WHSOUT.ACTUAL_LOADING_DATE AS \"actualLoadingDate\",\n" +
            "    WHSOUT.MONITOR_LOADING AS \"monitorLoading\",\n" +
            "    WHSOUT.CABINET_CHECK_RESULT AS \"cabinetCheckResult\",\n" +
            "    WHSOUT.REMARKS AS \"remarks\",\n" +
            "    MA.MATERIAL_ZH_DESC AS \"materialZhDesc\",\n" +
            "    MA.MATERIAL_EN_DESC AS \"materialEnDesc\",\n" +
            "    MA.UNIT_SALES AS \"unitSales\",\n" +
            "    MA.NET_WEIGHT AS \"netWeight\",\n" +
            "    MA.GROSS_WEIGHT AS \"grossWeight\",\n" +
            "    MA.WEIGHT_UNIT AS \"weightUnit\",\n" +
            "    MA.VOLUME_QTY AS \"volumeQty\",\n" +
            "    MA.VOLUME_UNIT AS \"volumeUnit\",\n" +
            "    (CASE WHEN MA.NUMERATOR IS NULL THEN 1 ELSE MA.NUMERATOR END ) AS \"numerator\",\n" +
            "    (CASE WHEN MA.DENOMINATOR IS NULL THEN 1 ELSE MA.DENOMINATOR END ) AS \"denominator\" ,\n" +
            "    MA.LIGHT_HEAVY_MARK AS \"lightHeavyMark\" \n" +
            "FROM\n" +
            "    SAP_PACKAGE_LIST_DTL SPLD\n" +
            "    LEFT JOIN WHS_OUT WHSOUT ON SPLD.WHS_OUT_UUID = WHSOUT.UUID\n" +
            "    LEFT JOIN MATERIAL_SAP MA ON SPLD.MATERIAL_NO = MA.MATERIAL_NO \n" +
            "WHERE\n" +
            "    SPLD.ACTUAL_OPERATE_QTY > 0 \n" +
            "    AND WHSOUT.TASK_STATUS IN ( '2', '4', '5' )\n" +
            "    <when test='cabinetNumber!=null'> AND WHSOUT.CABINET_NUMBER = #{cabinetNumber}</when>\n" +
            "    <when test='packageList!=null'> AND SPLD.PACKAGE_LIST = #{packageList}</when>\n" +
            "UNION \n" +
            "SELECT\n" +
            "    '其它出入库' AS \"Source\",\n" +
            "    WHSO.PACKAGE_LIST AS \"packageList\",\n" +
            "    WHSODTL.DATE_OF_LOADING AS \"dateOfLoading\",\n" +
            "    WHSODTL.WERKS AS \"loadingWerks\",\n" +
            "    WHSODTL.WHS_LOCATION_CODE AS \"loadingWhsLocationCode\",\n" +
            "    WHSODTL.CABINET_SERIAL_NUMBER AS \"cabinetSerialNumber\",\n" +
            "    WHSO.GOODS_TYPE AS \"goodsType\",\n" +
            "    WHSODTL.RECEIVING_WERKS AS \"receivingWerks\",\n" +
            "    WHSODTL.ACTUAL_RECEIVING_WERKS AS \"actualReceivingWerks\",\n" +
            "    WHSODTL.MATERIAL_NO AS \"materialNo\",\n" +
            "    WHSODTL.SHIPMENT_CATEGORY AS \"shipmentCategory\",\n" +
            "    WHSODTL.PLANNED_PACKING_QTY AS \"plannedPackingQty\",\n" +
            "    MA.BASIC_UNIT AS \"basicUnit\",\n" +
            "    WHSODTL.PLANNED_PACKING_NUMBER AS \"plannedPackingNumber\",\n" +
            "    WHSODTL.PACKAGE_UNIT AS \"packingUnit\",\n" +
            "    WHSODTL.CABINET_WEIGHT AS \"cabinetWeight\",\n" +
            "    WHSODTL.WEIGHT_UNIT AS \"weightUnit\",\n" +
            "    WHSODTL.CABINET_VOLUME AS \"cabinetVolume\",\n" +
            "    WHSODTL.VOLUME_UNIT AS \"volumeUnit\",\n" +
            "    WHSODTL.TRAILER_LINE AS \"trailerLine\",\n" +
            "    WHSODTL.TRAILER_LINE_DESC AS \"trailerLineDesc\",\n" +
            "    WHSODTL.SPMS_STATUS AS \"spmsStatus\",\n" +
            "    WHSODTL.WHS_OTHER_UUID AS \"outUuid\",\n" +
            "    WHSODTL.TEMP_STORAGE AS \"tempStorage\",\n" +
            "    WHSODTL.UNPLANNED AS \"unplanned\",\n" +
            "    WHSODTL.OPERATE_QTY AS \"actualOperateQty\",\n" +
            "    WHSODTL.CONTAINER_BRAND AS \"containerBrand\",\n" +
            "    WHSODTL.COLOR_NUMBER AS \"colorNumber\",\n" +
            "    WHSODTL.THICKNESS AS \"thickness\",\n" +
            "    WHSODTL.ACTUAL_AVG_GROSS_WEIGHT AS \"actualAvgGrossWeight\",\n" +
            "    WHSODTL.PACKAGE_QTY AS \"actualPackingNumber\",\n" +
            "    WHSODTL.CUSTOMS_DECLARATION_NUMBER AS \"customsDeclarationNumber\",\n" +
            "    WHSODTL.PACKING_SPEC AS \"packingSpec\",\n" +
            "    WHSODTL.LOADING_TYPE AS \"loadingType\",\n" +
            "    WHSODTL.CABINET_NUMBER AS \"cabinetNumber\",\n" +
            "    WHSO.SPMS_ID AS \"spmsId\",\n" +
            "    WHSODTL.LEAD_SEAL AS \"leadSeal\",\n" +
            "    WHSO.SAP_VOUCHER_NUMBER AS \"sapVoucherNumber\",\n" +
            "    WHSO.SAP_VOUCHER_YEAR AS \"sapVoucherYear\",\n" +
            "    WHSO.ACTUAL_LOADING_DATE AS \"actualLoadingDate\",\n" +
            "    WHSO.MONITOR_LOADING AS \"monitorLoading\",\n" +
            "    WHSO.CABINET_CHECK_RESULT AS \"cabinetCheckResult\",\n" +
            "    WHSODTL.ROW_REMARKS AS \"remarks\",\n" +
            "    MA.MATERIAL_ZH_DESC AS \"materialZhDesc\",\n" +
            "    MA.MATERIAL_EN_DESC AS \"materialEnDesc\",\n" +
            "    MA.UNIT_SALES AS \"unitSales\",\n" +
            "    MA.NET_WEIGHT AS \"netWeight\",\n" +
            "    MA.GROSS_WEIGHT AS \"grossWeight\",\n" +
            "    MA.WEIGHT_UNIT AS \"weightUnit\",\n" +
            "    MA.VOLUME_QTY AS \"volumeQty\",\n" +
            "    MA.VOLUME_UNIT AS \"volumeUnit\",\n" +
            "    (CASE WHEN MA.NUMERATOR IS NULL THEN 1 ELSE MA.NUMERATOR END ) AS \"numerator\",\n" +
            "    (CASE WHEN MA.DENOMINATOR IS NULL THEN 1 ELSE MA.DENOMINATOR END ) AS \"denominator\" ,\n" +
            "    MA.LIGHT_HEAVY_MARK AS \"lightHeavyMark\" \n" +
            "FROM\n" +
            "    WHS_OTHER_DTL WHSODTL\n" +
            "    LEFT JOIN WHS_OTHER_TASK WHSO ON WHSODTL.WHS_OTHER_UUID = WHSO.UUID\n" +
            "    LEFT JOIN MATERIAL_SAP MA ON WHSODTL.MATERIAL_NO = MA.MATERIAL_NO \n" +
            "WHERE\n" +
            "    WHSO.MOVEMENT_TYPE = 'Z641' \n" +
            "    AND WHSO.TASK_STATUS IN ( '3', '4', '5', '6' ) \n" +
            "    AND WHSO.GOODS_TYPE = 'M' \n" +
            "    <when test='cabinetNumber!=null'> AND WHSODTL.CABINET_NUMBER = #{cabinetNumber}</when>\n" +
            "    <when test='packageList!=null'> AND WHSO.PACKAGE_LIST = #{packageList}</when>\n" +
            "</script>")
    List<Map<String, Object>> outWHExportM(
            @Param("cabinetNumber") String cabinetNumber,
            @Param("packageList") String packageList
    );


    @Select("<script>\n" +
            "SELECT\n" +
            "    SBND.PACKAGE_NOTE AS \"packageNote\",\n" +
            "    SBND.BOX_NOTE AS \"boxNote\",\n" +
            "    SBND.MATERIAL_NO AS \"materialNo\",\n" +
            "    SBND.QUANTITY AS \"qty\",\n" +
            "    SBND.BASIC_UNIT AS \"basicUnit\",\n" +
            "    SBND.SRM_CONTRACT_NO AS \"srmContractNo\",\n" +
            "    SBND.PURCHASE_NO AS \"purchaseNo\",\n" +
            "    SBND.DELIVERY_NOTE_SAP AS \"deliveryNoteSap\",\n" +
            "    SBND.DEMAND_NO AS \"demandNo\",\n" +
            "    SBND.DEMAND_NO_ITEM AS \"demandNoItem\",\n" +
            "    MA.MATERIAL_ZH_DESC AS \"materialZhDesc\",\n" +
            "    MA.MATERIAL_EN_DESC AS \"materialEnDesc\",\n" +
            "    MA.PRODUCT_LEVEL_SMALL_DESC AS \"productLevelSmallDesc\",\n" +
            "    WHS.WERKS AS \"werks\",\n" +
            "    WHS.WHS_LOCATION_CODE AS \"whsLocationCode\",\n" +
            "    WHS.STORAGE_NO AS \"storageNo\" \n" +
            "FROM\n" +
            "    SAP_BOX_NOTE_DTL SBND\n" +
            "    LEFT JOIN MATERIAL_SAP MA ON SBND.MATERIAL_NO = MA.MATERIAL_NO\n" +
            "    LEFT JOIN WHS_STORAGE_INVENTORY WHSI ON WHSI.BOX_NOTE = SBND.BOX_NOTE\n" +
            "    LEFT JOIN WHS_STORAGE WHS ON WHSI.UUID = WHS.UUID \n" +
            "WHERE 1 = 1 \n" +
            "    <when test='boxNote!=null'> AND SBND.BOX_NOTE = #{boxNote}</when>\n" +
            "    <when test='materialNo!=null'> AND SBND.MATERIAL_NO = #{materialNo}</when>\n" +
            "    <when test='demandNo!=null'> AND SBND.DEMAND_NO = #{demandNo}</when>\n" +
            "    <when test='packageNote!=null'> AND SBND.PACKAGE_NOTE = #{packageNote}</when>\n" +
            "    <when test='purchaseNo!=null'> AND SBND.PURCHASE_NO = #{purchaseNo}</when>\n" +
            "    <when test='deliveryNoteSap!=null'> AND SBND.DELIVERY_NOTE_SAP = #{deliveryNoteSap}</when>\n" +
            "    <when test='srmContractNo!=null'> AND SBND.SRM_CONTRACT_NO = #{srmContractNo}</when>\n" +
            "</script>")
    List<Map<String, Object>> queryBoxInfo(
            @Param("boxNote") String boxNote,
            @Param("materialNo") String materialNo,
            @Param("demandNo") String demandNo,
            @Param("packageNote") String packageNote,
            @Param("purchaseNo") String purchaseNo,
            @Param("deliveryNoteSap") String deliveryNoteSap,
            @Param("srmContractNo") String srmContractNo
    );

}
